import axios from 'axios'
const service = axios.create({
    baseURL: process.env.VUE_APP_MOCK_API,
    timeout: 6000000 // 请求超时时间
})

service.interceptors.request.use(
    config => {
        return config
    },
    error => {
        Promise.reject(error)
    }
)

// response 拦截器
service.interceptors.response.use(
    response => {
        const { status } = response
        switch (status) {
            case 200:
                return response.data
            case 400:
                console.log(response.data.message)
                break
        }
    },
    error => {
        return Promise.reject(error)
    }
)
export default service
